<?php

/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

namespace app\user\controller;
use cmf\controller\UserBaseController;
use think\Db;
use think\Request;
/**
 * Description of ResourceController
 *
 * @author Administrator
 */
class ResourceController extends UserBaseController{
    
    public function iconList(){
        $a = $this->request->get('a/s');
        $pdata = Db::name('game_resource')->where('filetype','icon')->paginate(2);
        $data = ['icons'=>$pdata->items(),'page'=>$pdata->render(),'arga'=>$a];
        $this->result($data,0,'请求成功','json');
    }
    
    public function resourceList(){
        $data = Request::instance()->param();
    	$filetype = isset($data['filetype']) ? $data['filetype'] : 'logo';
    	$data = Db::name('game_resource')
                ->field(['file_path', 'price','filename', 'id'])->where(['filetype'=>$filetype, 'enable_i'=>1])->select();
        $r = [];
        foreach ($data as $key => $value) {
          array_push($r, [
            'fileurl'=>cmf_get_image_preview_url($data[$key]['file_path']),
            'price'=>$data[$key]['price'],
            'filename'=>$data[$key]['filename'],
            'id'=>$data[$key]['id']]
          );
        }
    	$this->result($r,1,'请求成功','json',[], 'status');	
    }

    public function package(){
        return $this->fetch('/package');
    }
}
